﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EZCRS.HCMS.Entity;
using EZCRS.HCMS.Data;

namespace EZCRS.HCMS.SqlClient
{
    public class sql_hcrs_district
    {
        string sqlstr = "";
        /// <summary>
        /// 返回全部列表
        /// </summary>
        /// <returns></returns>
        public List<HCRS_District> getalldistrict(int id)
        {
            sqlstr = "select * from HCRS_District";
            if (id > 0)
                sqlstr = "select * from HCRS_District where cityid=" + id.ToString() ;
            return ExecSql.GetTableList<HCRS_District>(sqlstr);
        }

        /// <summary>
        /// 返回单条信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public HCRS_District getitem(int id)
        {
            return new HCRS_District(ExecSql.GetDataSet("select * from HCRS_District where DistrictID=" + id.ToString() + " ").Tables[0].Rows[0]);
        }

        /// <summary>
        /// 删除单条信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool deldistrict(int id)
        {
            if (ExecSql.SqlExecNoquery("delete from HCRS_District where DistrictID=" + id.ToString() + "") > 0)
                return true;
            else
                return false;
        }

        /// <summary>
        /// 新增或更新
        /// </summary>
        /// <param name="_district"></param>
        /// <returns></returns>
        public bool insertorupdate(HCRS_District _district)
        {
            return ExecSql.InsertOrUpdateData<HCRS_District>(_district);
        }
    }
}
